package com.moyu.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moyu.admin.entity.TUserInfo;
import com.moyu.admin.service.SysUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author moyu
 * @since 2019-02-18
 */
@Controller
@RequestMapping("/admin/user")
public class SysUserController {

  @Autowired
  private SysUserInfoService sysUserInfoService;

  @RequestMapping("/index")
  public String index(){
    return "admin/user/list";
  }

  @RequestMapping("/list")
  @ResponseBody
  public Page<TUserInfo> list() {
    Page<TUserInfo> page = sysUserInfoService.selectPage(new Page<TUserInfo>(0, 12));
    return page;
  }

  @RequestMapping("/add")
  public String create(TUserInfo user) {
    user.setUserId(2L);
    user.insert();
    return index();
  }
}


